package com.hp.beanstalk;

import com.dinstone.beanstalkc.Job;
import com.dinstone.beanstalkc.JobConsumer;
import com.dinstone.beanstalkc.JobProducer;
import com.hp.entity.request.AlarmContentRequest;
import com.hp.entity.request.ContentRequest;
import com.hp.entity.response.MessageResponse;
import com.hp.service.SendMessageService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * @author hp
 */
@RestController
@RequestMapping("/beanstalk")
public class BeanStalkController {

    @Resource
    private JobProducer jobProducer;

    @Resource
    private JobConsumer jobConsumer;


    @GetMapping("/send")
    public void send() {
        jobProducer.putJob(1, 1, 5000, "dddd".getBytes());
    }

    @GetMapping("/recept")
    public String recept() {
        Job job = jobConsumer.reserveJob(5);
        String json = new String(job.getData());
        String s = "id = " + job.getId() + " ; data = " + json;
        System.out.println(s);
        return json;
    }


}
